#ifndef __SCNS_TIMER_H__
#define __SCNS_TIMER_H__

#include "ScnsConfig.h"

#if defined(SCNS_TIMER_ENABLE)&&SCNS_TIMER_ENABLE==1

#include "ScnsBspTimer.h"

#include "ScnsYing.h"

typedef enum
{
    SCNS_TIMER_STATUS_OK=SCNS_YING_STATUS_OK,
    SCNS_TIMER_STATUS_BSP_FAILED=SCNS_YING_STATUS_BSP_FAILED,
    SCNS_TIMER_STATUS_FAILED=SCNS_YING_STATUS_FAILED,
    SCNS_TIMER_STATUS_TIME_OU=SCNS_YING_STATUS_TIME_OUT,
}ScnsTimerStatus;

#define scnsTimerGetFps(us) (1000000ULL/((us)+1))
extern ScnsTimerStatus scnsTimerInit(void);
extern void scnsTimerMarkInited(void);

extern void scnsTimerSetTick(uint64 tick);
extern uint64 scnsTimerGetTick(void);
extern uint64 scnsTimerGetInitedTick(void);

extern void scnsDelayNs(uint64 ns);
extern void scnsDelayUs(uint64 us);
extern void scnsDelayMs(uint64 ms);

extern uint64 scnsTimerGetNsByTick(uint64 tick);
extern uint64 scnsTimerGetUsByTick(uint64 tick);
extern uint64 scnsTimerGetMsByTick(uint64 tick);

extern uint64 scnsTimerGetTickByNs(uint64 ns);
extern uint64 scnsTimerGetTickByUs(uint64 us);
extern uint64 scnsTimerGetTickByMs(uint64 ms);

extern uint64 scnsTimerGetNs(void);
extern uint64 scnsTimerGetUs(void);
extern uint64 scnsTimerGetMs(void);

extern uint64 scnsTimerGetInitedNs(void);
extern uint64 scnsTimerGetInitedUs(void);
extern uint64 scnsTimerGetInitedMs(void);

extern void scnsTimerTest(void);

extern void scnsTimerSysTickHandler(void);

#endif
#endif
